<template id="BuyNotes">
  <div class="buyNotes">
    <el-dialog
      :visible.async="options"
      :show-close="false"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      center
      top="30vh"
    >
      <p class="notesTitle">购买须知</p>
      <span class="notesDesc">{{ desc }}</span>
      <div class="noTips">
        <div
          class="tipClick"
          :class="{ isClick: isShowBuyTips }"
          @click="neverTip"
        ></div>
        <p :class="{ isClickP: isShowBuyTips }" @click="neverTip">
          我已知晓，下次不再提示
        </p>
      </div>
      <span slot="footer" class="dialog-footer">
        <div class="pc">
          <div class="btn" @click="cancel">取消</div>
          <div class="btn continue" @click="continueBuy">继续购买</div>
        </div>
        <div class="phone">
          <div class="btn" @click="cancel">取消</div>
          <div class="btn continue" @click="continueBuy">继续购买</div>
        </div>
      </span>
    </el-dialog>
  </div>
</template>

<script>
// 这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
import { mapState, mapMutations } from "vuex";
export default {
  name: "buyNotes",
  components: {},
  props: {
    options: {
      type: Boolean,
    },
  },
  // 定义属性
  data() {
    return {
      desc:
        "本商品仅限年满18周岁且实名认证的用户购买。该数字藏品是虚拟商品，并非实物，由于数字藏品的特殊性，一经售出，均不支持退换！数字藏品的版权归发行方或权利人所有，数字藏品不支持任何形式的炒作和非法使用请谨慎购买。",
    };
  },
  // 计算属性，会监听依赖属性值随之变化
  computed: {
    ...mapState(["isShowBuyTips"]),
  },
  // 监控data中的数据变化
  watch: {},
  // 方法集合
  methods: {
    ...mapMutations(["neverTip"]),
    //取消
    cancel() {
      this.$emit("cancelNotes");
    },
    //继续购买
    continueBuy() {
      this.$emit("continueBuy");
    },
  },
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  beforeCreate() {}, // 生命周期 - 创建之前
  beforeMount() {}, // 生命周期 - 挂载之前
  beforeUpdate() {}, // 生命周期 - 更新之前
  updated() {}, // 生命周期 - 更新之后
  beforeDestroy() {}, // 生命周期 - 销毁之前
  destroyed() {}, // 生命周期 - 销毁完成
  activated() {}, // 如果页面有keep-alive缓存功能，这个函数会触发
};
</script>

<style lang="less" scoped>
.buyNotes {
  p {
    margin: 0;
  }

  // /deep/.el-dialog__wrapper {
  //   transition-duration: 5s;
  // }

  /deep/.el-dialog {
    width: 500px;
    background: #1e2020;
    border-radius: 10px;

    .el-dialog__header {
      display: none;
    }

    .el-dialog__body {
      .notesTitle {
        font-size: 18px;
        font-family: PingFangSC-Semibold, PingFang SC;
        font-weight: 600;
        color: #ffffff;
        text-align: center;
        margin-bottom: 20px;
      }

      .notesDesc {
        font-size: 14px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #666666;
      }

      .noTips {
        margin-top: 20px;
        display: flex;
        align-items: center;

        p {
          margin: 0;
          font-size: 14px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #666666;
          cursor: pointer;
        }

        .isClickP {
          color: #00ffb0;
        }

        .tipClick {
          cursor: pointer;
          background: url("~@/assets/images/buyNotes/unClick.png");
          width: 14px;
          height: 14px;
          background-size: 100% 100%;
          margin-right: 10px;
        }

        .isClick {
          background: url("~@/assets/images/buyNotes/onClick.png");
          width: 14px;
          height: 14px;
          background-size: 100% 100%;
        }
      }
    }

    .el-dialog__footer {
      .dialog-footer {
        .pc {
          display: flex;
          justify-content: flex-end;

          .btn {
            cursor: pointer;
            padding: 10px 18px;
            font-size: 14px;
            font-family: PingFangSC-Medium, PingFang SC;
            font-weight: 500;
            color: #999999;
            background: #1e2020;
            border-radius: 4px;
            border: 1px solid #666666;
          }

          .continue {
            margin-left: 15px;
            color: #1e2020;
            background: #00ffb0;
          }
        }

        .phone {
          display: none;
        }
      }
    }
  }
}

@media screen and (max-width: 768px) {
  .buyNotes {
    /deep/.el-dialog {
      width: 75%;

      .el-dialog__body {
        padding: 50px;

        .notesTitle {
          font-size: 36px;
          margin-bottom: 30px;
        }

        .notesDesc {
          font-size: 24px;
          line-height: 1.5;
        }

        .noTips {
          .tipClick,
          .isClick {
            width: 24px;
            height: 24px;
            margin-right: 20px;
          }

          p {
            font-size: 24px;
          }
        }
      }

      .el-dialog__footer {
        border-top: 2px #888888 solid;
        padding: 0;

        .dialog-footer {
          .pc {
            display: none;
          }

          .phone {
            display: flex;
            justify-content: space-between;

            .btn {
              padding: 40px 0;
              flex: 1;
              font-size: 36px;
              font-family: PingFangSC-Medium, PingFang SC;
              font-weight: 500;
              color: #999999;
            }

            .continue {
              color: #00ffb0;
              border-left: 2px #888888 solid;
            }
          }
        }
      }
    }
  }
}
</style>
